package wfmanage.action;

import com.opensymphony.xwork2.ActionSupport;
import com.util.MyLog;

import edu.wfmanage.models.Ticket;
import java.sql.Date;
import java.util.ArrayList;

import edu.wfmanage.models.HelpDeskUser;

public class ForwardTicket extends ActionSupport{
	
	private int id;
	private String summary = "";
	private String category = "";
	private String device = "";
	private String os = "";
	private Date date;
	private String priority = "";
	private String cust_name = "";
	private String email = "";
	private String dept = "";
	private String office = "";
	private String phone = "";
	private String desc = "";
	private String comments = "";
	private String status;
	private String support_level;
	
	private ArrayList<HelpDeskUser> userlist = new ArrayList<HelpDeskUser>();
	
	
	public String execute() throws Exception{
		MyLog.log("IN execute of forward tkt page");
		MyLog.log(support_level);
//		MyLog.log(id);
		Ticket ticket = new Ticket();
		ticket.updateStatusbyAdmin(status, id, support_level);
		userlist = HelpDeskUser.findUserList(support_level);
		MyLog.log("userlist size is"+userlist.size());
		email mail=new email();
        for(HelpDeskUser u: userlist){
        	MyLog.log("\n66666666666666666666666666\n");
    		MyLog.log("Username = " + u.getUsername());
    		MyLog.log("Userid = " + u.getUserid());
    		MyLog.log("Password = " + u.getPassword());
    		MyLog.log("Email = " + u.getEmailid());
    		MyLog.log("Support_level = " + support_level);
             mail.sendmail(u.getUsername(),u.getEmailid(),support_level,0, "NA");
             MyLog.log("An email has been sent to "+u.getEmailid());
        }
		return "success";
		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getDevice() {
		return device;
	}

	public void setDevice(String device) {
		this.device = device;
	}

	public String getOs() {
		return os;
	}

	public void setOs(String os) {
		this.os = os;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getPriority() {
		return priority;
	}

	public void setPriority(String priority) {
		this.priority = priority;
	}

	public String getCust_name() {
		return cust_name;
	}

	public void setCust_name(String cust_name) {
		this.cust_name = cust_name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDept() {
		return dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public String getOffice() {
		return office;
	}

	public void setOffice(String office) {
		this.office = office;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getSupport_level() {
		return support_level;
	}

	public void setSupport_level(String support_level) {
		this.support_level = support_level;
	}

	public ArrayList<HelpDeskUser> getUserlist() {
		return userlist;
	}

	public void setUserlist(ArrayList<HelpDeskUser> userlist) {
		this.userlist = userlist;
	}
	
		
}
